﻿<Window x:Class="Brjnk.GpxExplorer.UI.ManageExternalApplicationsWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:l="clr-namespace:Brjnk.GpxExplorer.Localization"
        FocusManager.FocusedElement="{Binding ElementName=okButton}"
        WindowStartupLocation="CenterOwner"
        Title="{l:Loc titleManageExternalApps}" MinHeight="360" MinWidth="400" Width="400" Height="360">
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="3*" />
            <ColumnDefinition Width="1*" />
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>

        <StackPanel Orientation="Vertical">
            <TextBlock Text="{l:Loc manageExternalApplicationsInfo}" TextWrapping="Wrap" />
        </StackPanel>

        <ListView Grid.RowSpan="3"  Grid.Row="1" Name="applications" SelectionMode="Single" ItemsSource="{Binding CustomExternalApplications}">
            <ListView.ItemTemplate>
                <DataTemplate>
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="*" />
                        </Grid.ColumnDefinitions>
                        <Image Width="32" Source="{Binding Icon}" />
                        <TextBlock Grid.Column="1" Text="{Binding Name}" />
                    </Grid>
                </DataTemplate>
            </ListView.ItemTemplate>
        </ListView>

        <Button Grid.Column="1" Grid.Row="0" Content="{l:Loc ok}" VerticalAlignment="Top" Click="Button_Click" Name="okButton" />
        <Button Grid.Column="1" Grid.Row="1" VerticalAlignment="Top"  Content="{l:Loc manageExternalApplicationsAddCommand}" Command="{Binding AddExternalApplicationCommand}" />
        <Button Grid.Column="1" Grid.Row="2" VerticalAlignment="Top"  Content="{l:Loc manageExternalApplicationsRemoveCommand}" Command="{Binding RemoveExternalApplicationCommand}" CommandParameter="{Binding ElementName=applications, Path=SelectedItem}" />

        <Grid Grid.Row="4" Grid.ColumnSpan="2">
            <Grid.Style>
                <Style>
                    <Style.Triggers>
                        <DataTrigger Binding="{Binding ElementName=applications, Path=SelectedItems.Count}" Value="0">
                            <Setter Property="Grid.IsEnabled" Value="False" />
                        </DataTrigger>
                    </Style.Triggers>
                </Style>
            </Grid.Style>
            <Grid.RowDefinitions>
                <RowDefinition />
                <RowDefinition />
                <RowDefinition />
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition />
            </Grid.ColumnDefinitions>

            <TextBlock Grid.Row="0" Text="{l:Loc manageExternalApplicationsName}" />
            <TextBlock Grid.Row="1" Text="{l:Loc manageExternalApplicationsPath}" />

            <TextBox Grid.Row="0" Grid.Column="1" Text="{Binding ElementName=applications, Path=SelectedItem.NameSerializable}" />
            <TextBox Grid.Row="1" Grid.Column="1" Text="{Binding ElementName=applications, Path=SelectedItem.PathSerializable}" />
            <CheckBox IsThreeState="True" Grid.Row="2" Grid.ColumnSpan="2" IsChecked="{Binding ElementName=applications, Path=SelectedItem.UseGcGpx}" Content="{l:Loc manageExternalApplicationsUseGcGpx}" />
        </Grid>
    </Grid>
</Window>